package com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.R;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.model.Doctor;

import java.util.List;

public class DoctorAdapter extends RecyclerView.Adapter<DoctorAdapter.ViewHolder> {

    private List<Doctor> dataList;
    private Context context;

    public DoctorAdapter(List<Doctor> dataList, Context context) {
        this.dataList = dataList;
        this.context = context;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView avatarImage;
        TextView nameValue;
        TextView capacityLabel;

        public ViewHolder(View view) {
            super(view);
            avatarImage = view.findViewById(R.id.avatar_image);
            nameValue = view.findViewById(R.id.name_value);
            capacityLabel = view.findViewById(R.id.capacity_value);
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_doctor, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        Doctor doctor = dataList.get(position);
//        byte[] imageBytes = doctor.getAvatarBytes();
        /*if (imageBytes != null) {
            Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
            holder.avatarImage.setImageBitmap(bitmap);
        }*/
        holder.nameValue.setText(doctor.getName());
        holder.capacityLabel.setText(doctor.getCapacity());
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }
}
